package xyz.scootaloo.oj.leetcode

/**
 * 未完成
 * @author flutterdash@qq.com
 * @since 2021/4/7 22:48
 */
class P31 {

    /**
     * [1, 2, 3]  [2, 1, 3, 4, 5] <-
     * [1, 3, 2]  [2, 1, 3, 5, 4] <-
     * [2, 1, 3]
     * [2, 3, 1]  [2, 1, 5, 4, 3]
     *                ^
     * [3, 1, 2]  [2, 3, 1, 5, 4]
     * [3, 2, 1]
     */
    fun nextPermutation(nums: IntArray): Unit {
        var pivot = -1
        for (idx in nums.size - 2 downTo 0) {
            if (nums[idx] < nums[idx + 1]) {
                pivot = idx
                break
            }
        }
        if (pivot == -1) {
            nums.sort()
            return
        }

        val pivotValue = nums[pivot]

    }

}
